<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/11/21
  Time: 12:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/static/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/dialog.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .supplierName{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .creditCode{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .contactName{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .phone{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .email{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .address{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .registeredCapital{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .registrationDate{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .scope {
              width: 40px;
              white-space: nowrap; /* 文本不换行 */
              overflow: hidden; /* 超出部分隐藏 */
              text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .registrationAuthority{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
        .type{
            width: 40px;
            white-space: nowrap; /* 文本不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 溢出部分显示省略号 */
        }
    </style>
</head>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  action="${pageContext.request.contextPath}/supplier/getList.do" method="get" onsubmit="return toUser()">
            <input id="name" type="text" name="name" placeholder="请输入供货商名称" value="${name}" autocomplete="off" class="layui-input">
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show1('新增供货商',1000,600,1)"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：${pageInfo.total} 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>id</th>
            <th>供应商名称</th>
            <th>社会统一信用代码</th>
            <th>联系人名称</th>
            <th>联系电话</th>
            <th>电子邮箱</th>
            <th>地址</th>
            <th>注册资本</th>
            <th>注册时间</th>
            <th>经营范围</th>
            <th>登记机关</th>
            <th>企业类型</th>
            <th>所属行业</th>
            <th>工商注册号</th>
            <th>纳税人识别号</th>
            <th>操作</th>
        </tr>
        </thead>
        <c:forEach var="item" items="${pageInfo.list}">
            <tbody>
                <tr>
                    <td>
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='${item.supplierId}'><i class="layui-icon">&#xe605;</i></div>
                    </td>
                    <td style="width: 20px">${item.supplierId}</td>
                    <td>
                        <p class="supplierName">${item.supplierName}</p>
                    </td>
                    <td>
                        <p class="creditCode">${item.creditCode}</p>
                    </td>
                    <td>
                        <p class="contactName">${item.contactName}</p>
                    </td>
                    <td>
                        <p class="phone">${item.phone}</p>
                    </td>
                    <td>
                        <p class="email">${item.email}</p>
                    </td>
                    <td>
                        <p class="address">${item.address}</p>
                    </td>
                    <td>
                        <p class="registeredCapital">${item.registeredCapital}</p>
                    </td>
                    <td>
                        <p class="registrationDate">${item.registrationDate}</p>
                    </td>
                    <td>
                        <p class="scope">${item.scope}</p>
                    </td>
                    <td>
                        <p class="registrationAuthority">${item.registrationAuthority}</p>
                    </td>
                    <td>
                        <p class="type">${item.type}</p>
                    </td>
                    <td>
                        <p class="type">${item.industry}</p>
                    </td>
                    <td>
                        <p class="type">${item.registeredNo}</p>
                    </td>
                    <td>
                        <p class="type">${item.registrationNumber}</p>
                    </td>
                    <td class="td-manage type">
                        <a title="查看" id="getSupplier" onclick="x_admin_show1('查看供货商',1000,600,2,${item.supplierId})" href="javascript:;">
                            <i class="layui-icon">&#xe63c;</i>
                        </a>
                        <a title="编辑"  onclick="x_admin_show1('修改供货商',1000,600,3,${item.supplierId})" href="javascript:;">
                            <i class="layui-icon">&#xe642;</i>
                        </a>
                    </td>
                </tr>
            </tbody>
        </c:forEach>
    </table>
    <div class="page">
        <div>
            <ul class="pagination">
                <li>
                    <a class="prev" href="javascript:go(1)" aria-label="Previous">首页</a>
                </li>
                <c:choose>
                    <c:when test="${pageInfo.pageNum > 1}">
                        <c:if test="${pageInfo.hasPreviousPage}">
                            <li><a class="prev" href="javascript:go(${pageInfo.prePage})">上一页</a></li>
                        </c:if>
                    </c:when>
<%--                    <c:otherwise>--%>
<%--                        <a class="" href="javascript:go(${pageInfo.pageNum})"></a>--%>
<%--                    </c:otherwise>--%>
                </c:choose>
                <c:choose>
                    <c:when test="${pageInfo.pages <= 10}">
                        <c:set var="begin" value="1"></c:set>
                        <c:set var="end" value="${pageInfo.pages}"></c:set>
                    </c:when>
                    <c:otherwise>
                        <c:set var="begin" value="${pageInfo.pageNum - 5}"></c:set>
                        <c:set var="end" value="${pageInfo.pageNum + 4}"></c:set>
                        <c:if test="${begin < 1}">
                            <c:set var="begin" value="1"></c:set>
                            <c:set var="end" value="10"></c:set>
                        </c:if>
                        <c:if test="${end > pageInfo.pages}">
                            <c:set var="begin" value="${pageInfo.pages - 9}"></c:set>
                            <c:set var="end" value="${pageInfo.pages}"></c:set>
                        </c:if>
                    </c:otherwise>
                </c:choose>
                <c:forEach var="i" begin="${begin}" end="${end}">
                    <c:choose>
                        <c:when test="${pageInfo.pageNum == i}">
                            <li><span class="current" style="color: blue">${i}</span></li>
                        </c:when>
                        <c:otherwise>
                            <li><a class="num" href="javascript:go(${i})">${i}</a></li>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
                <c:choose>
                    <c:when test="${pageInfo.pageNum < pageInfo.pages}">
                        <c:if test="${pageInfo.hasNextPage}">
                            <li><a class="next" href="javascript:go(${pageInfo.nextPage})">下一页</a></li>
                        </c:if>
                    </c:when>
<%--                    <c:otherwise>--%>
<%--                        <a class="next" href="javascript:go(${pageInfo.pages})"></a>--%>
<%--                    </c:otherwise>--%>
                </c:choose>
                <li>
                    <a class="next" href="javascript:go(${pageInfo.pages})" aria-label="Next">尾页</a>
                </li>
            </ul>
        </div>
    </div>
</div>
<script>
    function go(currPage){
        window.location.href = "${pageContext.request.contextPath}/supplier/getList.do?currPage="+currPage+"&pageSize=${pageInfo.pageSize}&supName=${name}"
    }
    function toUser(){
        window.location.href = "${pageContext.request.contextPath}/supplier/getList.do?currPage=1&pageSize=${pageInfo.pageSize}&supName="+$("#name").val()
        return true;
    }
    $("#btn_ref").click(function () {
        $("#name").val("")
    })
    function toUpUser(item) {
        console.log(item)
    }
    function delAll () {
        var data = tableCheck.getData();
        let ids = []
        ids.push(data)
        console.log(data);
        console.log(ids[0]);
        layer.confirm('确认要删除吗？'+data,function(index){
            window.location.href = "${pageContext.request.contextPath}/supplier/deleteSupplier.do?ids="+data
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
        });
    }
    function x_admin_show1(title,w,h,state,data){
        let url = ""
        if (title == null || title == '') {
            title=false;
        };
        if(state === 1){
            url = "${pageContext.request.contextPath}/jsp/erpInsertSupplierForm.jsp"
        }else if(state === 2){
            url = "${pageContext.request.contextPath}/jsp/erpGetSupplierForm.jsp"
        }else{
            url = "${pageContext.request.contextPath}/jsp/erpUpdateSupplierForm.jsp"
        }
        if (w == null || w == '') {
            w=($(window).width()*0.9);
        };
        if (h == null || h == '') {
            h=($(window).height() - 50);
        };
        if(data !== null){
            $.get("${pageContext.request.contextPath}/supplier/getSupplier.do",{supplierId:data},function (data) {
                console.log(data);
                sessionStorage.setItem('data', JSON.stringify(data)); // 存储页面相关数据，先将对象转为字符串再存储
            })
        }
        layer.open({
            type: 2,
            area: [w+'px', h +'px'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade:0.4,
            title: title,
            content: url
        });
    }
</script>
</body>

</html>
